/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * HomeSidebar.java
 *
 * Created on May 12, 2011, 4:42:43 AM
 */

package gui;

import classes.userBet;
import client.Request;
import classes.User;

/**
 *
 * @author mayakreidieh
 */
public class HomeSidebar extends javax.swing.JPanel {

    User User = null;
    Request Client = null;

    /** Creates new form HomeSidebar */
    public HomeSidebar(User user, Request client) {
      //  User = new User();


        User = user; // ?
        Client = client;
        System.out.println(User.firstname);
        initComponents();

//        welcome.setText("Welcome, " + User.firstname);
        getCurrentBets();
        getComments();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        welcome = new javax.swing.JLabel();
        user_bets = new javax.swing.JLabel();
        more = new javax.swing.JLabel();
        user_bets1 = new javax.swing.JLabel();
        more2 = new javax.swing.JLabel();
        betTeam3 = new javax.swing.JLabel();
        p1 = new javax.swing.JPanel();
        betTeam1 = new javax.swing.JLabel();
        betOn1 = new javax.swing.JLabel();
        betAmount1 = new javax.swing.JLabel();
        p2 = new javax.swing.JPanel();
        betTeam2 = new javax.swing.JLabel();
        betOn2 = new javax.swing.JLabel();
        betAmount2 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel1 = new javax.swing.JLabel();

        setOpaque(false);

        welcome.setFont(new java.awt.Font("Helvetica", 1, 24)); // NOI18N
        welcome.setForeground(new java.awt.Color(255, 255, 255));
        welcome.setText("Welcome,");

        user_bets.setFont(new java.awt.Font("Helvetica", 1, 18));
        user_bets.setForeground(java.awt.Color.white);
        user_bets.setText("<html>Check out what people are <br>talking about</html>");

        more.setFont(new java.awt.Font("Helvetica", 0, 14));
        more.setForeground(java.awt.Color.white);
        more.setText("more");

        user_bets1.setFont(new java.awt.Font("Helvetica", 1, 18));
        user_bets1.setForeground(java.awt.Color.white);
        user_bets1.setText("Your current bets");

        more2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uefa/next.png"))); // NOI18N

        betTeam3.setFont(new java.awt.Font("Helvetica", 0, 14));
        betTeam3.setForeground(java.awt.Color.white);
        betTeam3.setText("You have X current bets");

        p1.setOpaque(false);

        betTeam1.setFont(new java.awt.Font("Helvetica", 0, 14));
        betTeam1.setForeground(java.awt.Color.white);
        betTeam1.setText("Something vs apple");

        betOn1.setFont(new java.awt.Font("Helvetica", 0, 14));
        betOn1.setForeground(java.awt.Color.white);
        betOn1.setText("Apple win");

        betAmount1.setFont(new java.awt.Font("Helvetica", 0, 14));
        betAmount1.setForeground(java.awt.Color.white);
        betAmount1.setText("$ 500");

        org.jdesktop.layout.GroupLayout p1Layout = new org.jdesktop.layout.GroupLayout(p1);
        p1.setLayout(p1Layout);
        p1Layout.setHorizontalGroup(
            p1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(p1Layout.createSequentialGroup()
                .add(p1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(betTeam1)
                    .add(p1Layout.createSequentialGroup()
                        .add(94, 94, 94)
                        .add(p1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(betAmount1)
                            .add(betOn1))))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        p1Layout.setVerticalGroup(
            p1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(p1Layout.createSequentialGroup()
                .add(betTeam1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(betOn1)
                .add(5, 5, 5)
                .add(betAmount1))
        );

        p2.setOpaque(false);

        betTeam2.setFont(new java.awt.Font("Helvetica", 0, 14));
        betTeam2.setForeground(java.awt.Color.white);
        betTeam2.setText("Something vs apple");

        betOn2.setFont(new java.awt.Font("Helvetica", 0, 14));
        betOn2.setForeground(java.awt.Color.white);
        betOn2.setText("Apple win");

        betAmount2.setFont(new java.awt.Font("Helvetica", 0, 14));
        betAmount2.setForeground(java.awt.Color.white);
        betAmount2.setText("$ 500");

        org.jdesktop.layout.GroupLayout p2Layout = new org.jdesktop.layout.GroupLayout(p2);
        p2.setLayout(p2Layout);
        p2Layout.setHorizontalGroup(
            p2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, p2Layout.createSequentialGroup()
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(p2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(betTeam2)
                    .add(p2Layout.createSequentialGroup()
                        .add(94, 94, 94)
                        .add(p2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(betAmount2)
                            .add(betOn2))))
                .addContainerGap())
        );
        p2Layout.setVerticalGroup(
            p2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(p2Layout.createSequentialGroup()
                .add(betTeam2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(betOn2)
                .add(5, 5, 5)
                .add(betAmount2))
        );

        jLabel1.setFont(new java.awt.Font("Helvetica", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText(User.firstname
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(user_bets1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 258, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(betTeam3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 165, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(layout.createSequentialGroup()
                        .add(more)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(more2))
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(p2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(p1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, user_bets, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 280, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(welcome, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 113, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 109, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(welcome, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(user_bets1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(betTeam3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(p1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(11, 11, 11)
                .add(p2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(more2)
                    .add(more))
                .add(27, 27, 27)
                .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(user_bets, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 37, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(354, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel betAmount1;
    private javax.swing.JLabel betAmount2;
    private javax.swing.JLabel betOn1;
    private javax.swing.JLabel betOn2;
    private javax.swing.JLabel betTeam1;
    private javax.swing.JLabel betTeam2;
    private javax.swing.JLabel betTeam3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel more;
    private javax.swing.JLabel more2;
    private javax.swing.JPanel p1;
    private javax.swing.JPanel p2;
    private javax.swing.JLabel user_bets;
    private javax.swing.JLabel user_bets1;
    private javax.swing.JLabel welcome;
    // End of variables declaration//GEN-END:variables


public void getCurrentBets(){

    userBet[] Bets = null;

 //   Bets = new userBet[4];
//    Client.getBets(3, String.valueOf(User.ID), Bets); //Gets all bets for user
    System.out.println(String.valueOf(User.ID));
    Bets = Client.getBets(3,String.valueOf(User.ID));
//*
    for (int i = 0; i<Bets.length; i++) {
               System.out.println("ID: "+Bets[i].getID());
                        System.out.println("Game: "+Bets[i].getGame());
                        System.out.println("Date: "+Bets[i].getDateAdded());
                        System.out.println("Status: "+Bets[i].getStatus());
                        System.out.println("Amount: "+Bets[i].getAmount());
    }

    int i,n =0;
    for (i=0; i<Bets.length;i++){
        if (Bets[i].getStatus() == 0)
            n++;
    }

    betTeam3.setText("You have "+n+" current bets!");


    if (n==0){

        p1.setVisible(false);
        p2.setVisible(false);
        // Print no pendinb bets
    }


    if (n>0){
        String[] games = null;
        games = Client.getGames("ID", Bets[0].getGame());
        String gameText = games[3]+"-"+games[4];
        betTeam1.setText(gameText);
        betOn1.setText(Bets[0].getType());
        betAmount1.setText("$" + Bets[0].getAmount());

        p2.setVisible(true);
    }

    if (n>1){
        String[] games = null;
        games = Client.getGames("ID", Bets[0].getGame());
        String gameText = games[3]+"-"+games[4];
        betTeam2.setText(gameText);
        betOn2.setText(Bets[1].getType());
        betAmount2.setText("$" + Bets[1].getAmount());
        p2.setVisible(true);
    }

    if (n>2){
        more.setVisible(true);
    }
  
// */
}

public void getComments(){

}

}
